import Request from '@/libs/request'
import qs from 'qs'

/**分页查询已发起考核 */
export const selectPmFormByPage = (
  data: {pmFormName?: string; datePeriodTypeCode?: string} & Paging
) => Request.get<PagingResponse<PmForm.TableData>>('/pmForm/selectPmFormByPage', data)

/**查询所有阶段以及各阶段的人数 */
export const selectStageAndUserCount = (data: {pmFormId: number}) =>
  Request.get<PmForm.StageAndUserCount[]>('/pmStage/selectStageAndUserCount', data)

/**多条件分页查询已发起考核的信息 */
export const selectPmByPage = (
  data: {
    pmFormId: number
    pmUserName?: string
    pmStatusCode?: string
    pmPeriodCode?: string
    pmStageCode?: PmGroupStageCode
    pmScoreLevel?: string
    pmDeptDDId?: string
  } & Paging
) => Request.get<PagingResponse<PmForm.BaseInfoTableData>>('/pm/selectPmByPage', data)

/**发起评分 获取考评组 和人员 */
export const selectPmFormUser = (data: {pmFormId: number}) =>
  Request.get<PmForm.UserAndEvaluationByPmForm>('/pmForm/selectPmFormUser', data)

/**发起评分 */
export const startScore = (data: {
  pmFormId: number
  pmGroupIdList?: string
  userDDList?: string
  startUserDDId: string
}) => Request.get<null>('/pmForm/startScore', data)

/**调整绩效结果 */
export const editPmScore = (data: {pmId: number; makeUserDDId: string; pmScore: number}) =>
  Request.get<null>('/pm/editPmScore', data)

/**绩效导出 */
export const exportPm = (data: {pmFormId: number}) =>
  Request.filePost('/pm/exportPm', qs.stringify(data), {responseType: 'blob'})

/**取消考评表 */
export const cancelPmForm = (data: {pmFormId: number; makeUserDDId: string}) =>
  Request.get<null>('/pmForm/cancelPmForm', data)

/**取消绩效 */
export const cancelPm = (data: {pmId: number; makeUserDDId: string}) =>
  Request.get<null>('/pm/cancelPm', data)
